1. Field
This disclosure generally relates to garbage collecting of objects from memory.
2. Background Art
Garbage collection, as used herein, is a form of memory management. A garbage collector will seek to collect and remove objects or other data structures that are stored in memory but are no longer being used. Garbage collection can occur at any time during system processing, but may also be configured to activate when the memory consumption has reached or is nearing capacity or another configured threshold. In many processing environments, many of the objects, variables and other data that are created or used during the execution of a program are stored in an area of memory known as the heap. As the heap fills up or reaches capacity, a garbage collector may be configured to clear the unused objects from the heap, so that the system can use the available memory for further allocations.
Conventional garbage collection schemes work by maintaining a root set of objects from which all objects that are currently in use are reachable. Whether or not an object is reachable from a node in the root set is determined by keeping track of the references among active objects. At the time of garbage collection, any objects that are not reachable from the root set are considered unused and may be de-allocated. The conventional garbage collection schemes may work adequately when all of the objects are from the same processing environment, because then the interdependencies between objects can be accurately determined. However, conventional garbage collection schemes cannot effectively determine which objects are to be cleared from a heap (e.g., are unused), when one or more of those objects correspond to or references one or more objects in another processing environment. As such, when objects in a first processing environment reference objects in a second processing environment, conventional garbage collection schemes may result in unused objects remaining in the heap or other memory portion even after garbage collection.
Leaving unused objects or other data structures within a heap, as may be done by conventional schemes, is referred to as a memory leak. These memory leaks may, over time, cause more and more of the memory accessible to an operating program to be consumed by unused objects, which may eventually cause the system to run out of memory for new objects necessary for continued execution of the system.